package tetris;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.util.Scanner;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Font;

public class InsertName extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	public static String nickname;
	private JTextArea txtPleaseEneterYour;

	public void run() {
		InsertName frame = new InsertName();
		frame.setVisible(true);
	}

	
	public InsertName() {
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setBounds(100, 100, 250,150);
		setUndecorated(true);
		setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setBackground(Color.DARK_GRAY);
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		textField = new JTextField();
		textField.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if( e.getKeyCode() == KeyEvent.VK_ENTER ) {
					nickname = textField.getText();
					StartGame game = new StartGame();
			        game.setLocationRelativeTo(null);
			        game.setVisible(true);
			        game.setBackground(Color.DARK_GRAY);
			        game.setDefaultCloseOperation(EXIT_ON_CLOSE);
			        GameMenu g = new GameMenu();
			        g.dispose();
			
				}
			}
		});
		textField.setBackground(Color.ORANGE);
		textField.setBounds(47, 86, 156, 47);
		textField.setDoubleBuffered(true);
		contentPane.add(textField);
		textField.setColumns(10);
		
		txtPleaseEneterYour = new JTextArea();
		txtPleaseEneterYour.setFont(new Font("Sathu", Font.PLAIN, 13));
		txtPleaseEneterYour.setText(" Please eneter your USERNAME \n            and then press ENTER\n");
		txtPleaseEneterYour.setEditable(false);
		txtPleaseEneterYour.setForeground(Color.WHITE);
		txtPleaseEneterYour.setBackground(Color.LIGHT_GRAY);
		txtPleaseEneterYour.setOpaque(true);
		txtPleaseEneterYour.setBounds(23, 20, 207, 47);
		contentPane.add(txtPleaseEneterYour);
		txtPleaseEneterYour.setColumns(10);
		txtPleaseEneterYour.setLineWrap(true);
		
	}
}
